package com.qnzw.zjmy.home.ui.activity;

import android.os.Bundle;

import com.android.volley.Request;
import com.qnzw.zjmy.R;
import com.qnzw.zjmy.config.UrlConfig;
import com.qnzw.zjmy.home.ui.adapter.GoodsAdapter;
import com.qnzw.zjmy.home.ui.model.Good;
import com.qnzw.zjmy.home.ui.model.vo.BaseVo;
import com.qnzw.zjmy.view.GoodsGridView;
import com.qnzw.zjmy.volley.BaseActivity;
import com.qnzw.zjmy.volley.state.HUCState;

import java.util.List;

public class LikeGoodsActivity extends BaseActivity {
    private GoodsGridView goodsGridView;
    private GoodsAdapter goodsAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_collect);
        super.onCreate(savedInstanceState);
        tvActionbarTitle.setText("喜欢");
        initGoods();
    }

    @Override
    public void initView() {
        super.initView();
        goodsGridView = findViewById(R.id.goods);
    }

    @Override
    public void onSuccessfulStrType(int inputType, Object response) {
        switch (inputType) {
            case HUCState.HUC_REQEUST_CODE_1:
                if (!(response instanceof List)) {
                    return;
                }
                goodsAdapter = new GoodsAdapter(this, (List<Good>) response);
                goodsGridView.setAdapter(goodsAdapter);
                break;
            default:
                break;
        }
    }

    private void initGoods() {
        BaseVo baseVo = new BaseVo();
        baseVo.setToken(getSharedPreferencesToken("token"));
        hucRequestInterfase.executeStr(this, Good.class, HUCState.HUC_REQEUST_CODE_1, Request.Method.POST, UrlConfig.URL_PRO_USER_LIKE_GOODS, hucParameInterfase.getRequestParameter(baseVo), false);
    }
}